package com.ewing.busi.carry.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.ewing.busi.carry.model.WebCarryTemplate;
import com.ewing.core.app.constant.IsEff;
import com.ewing.core.jdbc.BaseDao;

/**
 * 
 * @author tanson lam
 * @create Aug 27, 2016
 * 
 */
@Repository("carryTemplateDao")
public class CarryTemplateDao {
	@Resource
	private BaseDao baseDao;

	public List<WebCarryTemplate> findTemplateByShopId(Integer shopId) {
		String queryString = "shop_id=" + shopId + " AND iseff='"
				+ IsEff.EFFECTIVE + "'";
		return baseDao.find(queryString, WebCarryTemplate.class);
	}

	public WebCarryTemplate findTemplate(Integer templateId, Integer shopId) {
		String queryString = "shop_id=" + shopId + " AND id=" + templateId
				+ "  AND iseff='" + IsEff.EFFECTIVE + "'";
		return baseDao.findOne(queryString, WebCarryTemplate.class);
	}

	public WebCarryTemplate findTemplateByName(String templateName,
			Integer shopId) {
		String queryString = "shop_id=" + shopId + " AND name='" + templateName
				+ "' AND iseff='" + IsEff.EFFECTIVE + "'";
		return baseDao.findOne(queryString, WebCarryTemplate.class);
	}
}
